package com.spzx.order;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.core.web.domain.BaseEntity;

/**
 * @Author 快点干早点散
 * @Create 2025/4/28 20:52
 * Description:
 */
public class GenMP {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://192.168.6.100:3306/spzx-order?characterEncoding=utf-8&useSSL=false", "root", "root")
                .globalConfig(builder -> builder
                        .author("atguigu")
                        .outputDir("D:/spzx/order")
                        .dateType(DateType.ONLY_DATE)
//                        .disableOpenDir()
                )
                .packageConfig(builder -> builder
                        .parent("com.spzx.order")
                        .entity("domain")
                        .mapper("mapper")
                        .xml("mapper.order")
                        .service("service")
                        .serviceImpl("service.impl")
                        .controller("controller")
                )
                .strategyConfig(builder -> builder
                        .addInclude(
                                "order_info",
                                "order_item",
                                "order_log") // 设置需要生成的表名

                        .entityBuilder()
                        .enableLombok()
                        .superClass(BaseEntity.class)
                        .addSuperEntityColumns(
                                "id",
                                "create_by",
                                "create_time",
                                "update_by",
                                "update_time",
                                "remark",
                                "del_flag")
                        //.addIgnoreColumns
                        .enableFileOverride()

                        .serviceBuilder()
                        .formatServiceFileName("%sService")
                        .enableFileOverride()

                        .controllerBuilder()
                        .superClass(BaseController.class)
                        .enableRestStyle()
                        .enableFileOverride()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
